<template>
  <div class="tobeDone">
    <tableIndex
    ref="tableIndexRef"
      :tableData="tableData"
      :tableHead="tableHead"
      :isIndex="true"
      :isSelection="true"
      :isRadio="false"
      :fields="state.fields"
      :height="500"
      :page="page"
      @selectChange="selectChange"
      @searchList="searchList"
				@page-change="pageChange"
    >
      <!-- <template #btns>
        <div style="float: right">
          <el-button size="small" plain class="update"
            ><svg-icon icon-class="export" /> 导出</el-button
          >
        </div>
      </template> -->

      <template #operate>
        <el-table-column label="操作" width="400" align="center" fixed="right">
          <template #default="{ row }">
            <el-button
              size="small"
              class="button_view"
              type="primary"
              @click="infoDrawerHandler(row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </template>
    </tableIndex>
  </div>
</template>

<script setup>
import TableIndex from '@/components/table/index.vue'
import {
	projectConfigApi,
} from "@/api/project.js";

import { useRouter } from 'vue-router'
import { ref, onMounted, reactive } from 'vue'
let router = useRouter()

const state = reactive({
  fields: [
    { key: 'keywords', label: '项目名称', type: 'input', placeholder: '请输入项目名称' },
  ]
})
const info = ref(null)
const infoDrawer = ref(null)
const tableData = ref([

])
const tableHead = ref([
  {
    prop: 'projectId',
    label: '项目编号',
    width: '120'
  },
  {
    prop: 'projectName',
    label: '项目名称'
  },
  {
    prop: 'responsibleUserName',
    label: '责任人姓名'
  },{
    prop: 'createTime',
    label: '创建时间'
  },
  {
    prop: 'fileNum',
    label: '文件数量'
  },
])
const page = reactive({
	page: 1,
	pageSize: 50,
	total: 0,
});
const selectChange = (e) => {
}
//分页
const pageChange = (e) => {
	page.page = e.page;
	page.pageSize = e.limit;
	getPage();
};
const searchList = (e) => {
  getPage(e)
}
//查看
const infoDrawerHandler = (row) => {
  console.log(row);
  router.push({
    path: `/constructionProjectManage/dataManagement/components/datacomponents/id=${row.projectId}&projectTypeId=${row.projectTypeId}`,

  })
}
let tableIndexRef = ref(null);
//获取列表组件搜索数据
const getSearch = () => {
 return tableIndexRef.value.getSearchData()
}
const getPage = (param) => {
  projectConfigApi.getProjectPageList({
    pageNum:page.page,
    pageSize:page.pageSize,
    param:getSearch()
  }).then(res => {
    if (res.code == 200) {
      tableData.value = res.data.content
      page.total= res.data.totalSize
    }
  })
}

onMounted(() => {
  getPage()
})
</script>

<style lang="scss" scoped>
.tobeDone {
  width: 100%;
}
</style>
